package com.scorpio.elem;

import com.alibaba.fastjson.JSONObject;
import com.scorpio.api.Constants;

/**
 * 文本消息
 */
public class IMTextElem extends BaseElem {
    private String context;

    public IMTextElem() {
    }

    public IMTextElem(JSONObject jsonData) {
        setAcceptorId(jsonData.getString(Constants.EL_ACCEPTOR_ID));
        setContext(jsonData.getString(Constants.EL_CONTEXT));
        setIdentifying(jsonData.getString(Constants.EL_IDENTIFYING));
        setSenderId(jsonData.getString(Constants.EL_SENDER_ID));
    }

    public String getContext() {
        return context;
    }

    public void setContext(String context) {
        this.context = context;
    }

    @Override
    public JSONObject toMessageJson() {
        JSONObject json = new JSONObject();
        json.put(Constants.EL_ACCEPTOR_ID, getAcceptorId());
        json.put(Constants.EL_CONTEXT, getContext());
        json.put(Constants.EL_IDENTIFYING, getIdentifying());
        json.put(Constants.EL_SENDER_ID, getSenderId());
        json.put(Constants.EL_TIME, getTime());
        return json;
    }
}
